package main

import (
	"context"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"google.golang.org/grpc/grpclog"
	"grpc/demo/pb"
)

const ADDR = "127.0.0.1:9091"

func main() {
	conn, err := grpc.Dial(ADDR, grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		grpclog.Fatalln(err)
	}

	defer conn.Close()

	client := pb.NewHelloClient(conn)

	req := &pb.HelloRequest{Name: "hello client"}
	res, err := client.SayHello(context.Background(), req)

	if err != nil {
		grpclog.Fatalln(err)
	}

	grpclog.Println(res.Rsp)
}
